<?php
namespace app\manage\controller;
use think\Controller;

use app\common\model\Admin;
use think\Env;
class Index extends Controller
{
 
    public function index()
    {
        $this->redirect('main/index');

//        $this->redirect('index/logpage');
    }

    public function logpage(){

    	// 页面信息
        $pageData = ['title'=>'会员登录'];

        $this->assign('pageData',$pageData);
        return view();
    }

    public function login(){
    	$params = $this->request->post();

    	$validate = $this->validate($params,'Login.manage_login');
    	if(true!==$validate){
    		$this->error($validate);
    	}
    	$model = new Admin;

        if(!$admin=$model->where(['username'=>$params['username']])->find()){
            $this->error('用户名不存在');
        }

        if(!password_verify($params['password'],$admin['password'])){
            $this->error('密码错误');
        }

        session('admin',$admin);
        $this->success('登录成功',url('main/index'));
        //$this->redirect('main/index');

    }

    public function logout(){
    	session('admin',null);
        $this->redirect('index/logpage');
    }

    public function t1()
    {
//        $active = new \app\common\lib\Active();
//        $active->doActive(1, 2);
        $res = model('Member')->memberUpgrade();
        echo model('Member')->getError();
        halt($res);
    }

    public function imgUpload()
    {
        $file = $this->request->param();
        return json([111]);
    }
}
